@extends('admin.app')

@section('breadcrumb')
  <div class="bg-light lter b-b wrapper-md">
    <ol class="breadcrumb bg-light lter m-n no-padder">
      <li><a href="{{admin_action('HomeController@index')}}">主页</a></li>
      <li><a href="{{admin_action('Web\AdsController@index')}}">广告</a></li>
      <li class="active">编辑广告信息</li>
    </ol>
  </div>
@endsection

@section('content')
  <div class="panel panel-default">
    <div class="panel-heading font-bold">
      广告信息
    </div>
    <div class="panel-body">
      <form class="form-horizontal form-validation" action="{{ admin_action('Web\AdsController@update',[$ad]) }}" method="post" enctype="multipart/form-data">
        {{ csrf_field() }}
        {{ method_field('PUT') }}
        <div class="form-group">
          <label class="col-lg-2 control-label">名称*</label>
          <div class="col-lg-10">
            <input type="text" class="form-control" name="name" value="{{$ad->name}}" placeholder="请输入广告名称"
                   data-rule-required="true" data-rule-maxlength="100">
          </div>
        </div>
        <div class="line line-dashed b-b line-lg"></div>
        <div class="form-group">
          <label class="col-lg-2 control-label">图片*</label>
          <div class="col-lg-10">
            <input type="file" name="image" data-fileinput-image data-image-url="{{asset($ad->image)}}"/>
          </div>
        </div>
        <div class="line line-dashed b-b line-lg"></div>
        <div class="form-group">
          <label class="col-lg-2 control-label">广告类型*</label>
          <div class="col-lg-10">
            <select name="position" class="form-control select2">
              <option value>-----请选择广告位-----</option>
              @foreach ($positions as $position)
                <option value="{{$position->code}}" {{$ad->position==$position->code?'selected':''}}>{{$position->name}}</option>
              @endforeach
            </select>
          </div>
        </div>
        <div class="line line-dashed b-b line-lg"></div>
        <div class="form-group">
          <label class="col-lg-2 control-label">链接*</label>
          <div class="col-lg-10">
            <input type="text" class="form-control" name="link" value="{{$ad->link}}" placeholder="请输入链接"
                   data-rule-maxlength="200">
          </div>
        </div>
        <div class="line line-dashed b-b line-lg"></div>
        <div class="form-group">
          <label class="col-lg-2 control-label">描述*</label>
          <div class="col-lg-10">
            <textarea class="form-control" name="description" rows="5" data-rule-maxlength="200"
                      placeholder="请输入描述信息">{{$ad->description}}</textarea>
          </div>
        </div>
        <div class="line line-dashed b-b line-lg"></div>
        <div class="form-group">
          <label class="col-lg-2 control-label">排序*</label>
          <div class="col-lg-10">
            <input type="text" class="form-control" name="sort" value="{{$ad->sort}}" placeholder="请输入排序数字"
                   data-rule-required="true" data-rule-digits="true">
          </div>
        </div>
        <div class="line line-dashed b-b line-lg"></div>
        <div class="form-group">
          <div class="col-lg-4 col-lg-offset-2">
            <a href="{{ admin_action('Web\AdsController@index') }}" class="btn btn-default">返&nbsp;回</a>
            <button type="submit" class="btn btn-primary">保&nbsp;存</button>
          </div>
        </div>
      </form>
    </div>
  </div>
@endsection